/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1597058682457_2159';

  // add your middleware config here
  config.middleware = ['myErrorHander', 'auth'];

	// 不在auth验证token
	config.auth = {
		ignore: ['/reg', '/login', '/ws']
	}
	// config.websocket = {
	//   useAppMiddlewares: false,
	// };
	// config.socket = {
	// 	ignore: ['/reg', '/login']
	// }
  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
	
	config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
     // 跨域白名单
    domainWhiteList: [],
  };
  // 允许跨域的方法
  config.cors = {
    origin: '*',
    allowMethods: 'GET, PUT, POST, DELETE, PATCH'
  };
	
	config.sequelize = {
	    dialect:  'mysql',
	    host:  '127.0.0.1',
	    username: 'egg-wechat',
	    password:  'huiyani',
	    port:  3306,
	    database:  'egg-wechat',
	    // 中国时区
	    timezone:  '+08:00',
	    define: {
	        // 取消数据表名复数
	        freezeTableName: true,
	        // 自动写入时间戳 created_at updated_at
	        timestamps: true,
	        // 字段生成软删除时间戳 deleted_at
	        //paranoid: true,
	        createdAt: 'created_at',
	        updatedAt: 'updated_at',
	        //deletedAt: 'deleted_at',
	        // 所有驼峰命名格式化
	        underscored: true
	    }
	};
	// 参数校验
	config.valparams = {
	    locale    : 'zh-cn',
	    throwError: true
	};
	// crypto 数据加密(秘钥随便写，写了最好不要改）
	config.crypto = {
	    secret:  'qhdgw@45ncashdaksh2!#@3nxjdas*_672'
	};
	// jwt
	exports.jwt = {
	  secret: 'qhdgw@45ncashdaksh2!#@3nxjdas*_672'
	};
	// redis存储
	config.redis = {
		client: {
				port: 6379,          // Redis port
				host: '127.0.0.1',   // Redis host
				password: '',
				db: 0,
		},
	};
	
	// oss存储
	config.oss = {
		client: {
			accessKeyId: 'LTAI4G7caeDiPBzSzhNGqGj9',
			accessKeySecret: 'jOn0ke3eqntMt2oKYuHhrcv2RRwcvl',
			bucket: 'wechat12138',
			endpoint: 'oss-cn-beijing.aliyuncs.com',
			timeout: '60s',
		},
	}
	// oss文件上传
	config.multipart = {
	    mode: 'file',
			fileSize: 1048576000, 
			whitelist: ['.wmv','.png','.mp4','.mp3','.jpg','.jpeg'] 
	};
  return {
    ...config,
    ...userConfig,
  };
};
